package com.neusoft.service.impl;

import com.neusoft.entity.Employee;
import com.neusoft.mapper.EmployeeMapper;
import com.neusoft.service.EmployeeService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author akemihomurasama
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    /**
     * 根据条件查询医生
     *
     * @param deptmentId    部门id
     * @param registLevelId 级别id
     * @param schedulingId  排班id
     * @return 医生列表
     */
    @Override
    public Result queryEmpByCondition(int deptmentId, Integer registLevelId, int schedulingId) {
        return Result.ok(employeeMapper.queryEmpByCondition(deptmentId, registLevelId, schedulingId));
    }

    /**
     * 根据医生id查询医生信息
     *
     * @param id 医生id
     * @return 医生信息
     */
    @Override
    public Result queryEmpById(Integer id) {
        return Result.ok(employeeMapper.queryEmpById(id));
    }

    /**
     * 用户登录
     *
     * @param employee 用户登录信息
     * @return 登录结果
     */
    @Override
    public Result userLogin(Employee employee) {
        if (employee.getRealname() == "" || employee.getRealname() == null || employee.getPassword() == "" || employee.getPassword() == null) {
            return Result.fail("登录失败");
        }
        Employee employee1 = employeeMapper.queryEmpByNameAndPwd(employee);
        if (employee1 == null) {
            return Result.fail("登录失败");
        }

        return Result.ok(employee1);
    }
}
